package exception;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class TryCatchDemo01 {
    public static void main(String[] args) {
        FileOutputStream fos = null;

        try {
            fos = new FileOutputStream("jsd/fos.txt",true);
            fos.write(100);
//            System.exit(0);//只退出虚拟机finally才不会执行
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            System.out.println("finally");
            if (fos!=null){
                try {
                    fos.close();
                    fos=null;
                }catch (IOException e){
                    e.printStackTrace();
                }
            }
        }


    }
}
